| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 65 | rangePicker(){ |
||
| 66 | //Date range picker |
||
| 67 | $('.input-daterange-datepicker').daterangepicker({ |
||
| 68 | buttonClasses: ['btn', 'btn-sm'], |
||
| 69 | applyClass: 'btn-success', |
||
| 70 | cancelClass: 'btn-light' |
||
| 71 | }); |
||
| 72 | $('.input-daterange-timepicker').daterangepicker({ |
||
| 73 | timePicker: true, |
||
| 74 | timePickerIncrement: 30, |
||
| 75 | locale: { |
||
| 76 | format: 'MM/DD/YYYY h:mm A' |
||
| 77 | }, |
||
| 78 | buttonClasses: ['btn', 'btn-sm'], |
||
| 79 | applyClass: 'btn-success', |
||
| 80 | cancelClass: 'btn-light' |
||
| 81 | }); |
||
| 82 | $('.input-limit-datepicker').daterangepicker({ |
||
| 83 | format: 'MM/DD/YYYY', |
||
| 84 | minDate: '06/01/2018', |
||
| 85 | maxDate: '06/30/2018', |
||
| 86 | buttonClasses: ['btn', 'btn-sm'], |
||
| 87 | applyClass: 'btn-success', |
||
| 88 | cancelClass: 'btn-light', |
||
| 89 | dateLimit: { |
||
| 90 | days: 6 |
||
| 91 | } |
||
| 92 | }); |
||
| 93 | |||
| 94 | $('.reportrange span').html(moment().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + moment().format('MMMM D, YYYY')); |
||
| 95 | |||
| 96 | $('.reportrange').daterangepicker({ |
||
| 97 | format: 'MM/DD/YYYY', |
||
| 98 | startDate: moment().subtract(29, 'days'), |
||
| 99 | endDate: moment(), |
||
| 100 | minDate: '01/01/2017', |
||
| 101 | maxDate: '12/31/2020', |
||
| 102 | dateLimit: { |
||
| 103 | days: 60 |
||
| 104 | }, |
||
| 105 | showDropdowns: true, |
||
| 106 | showWeekNumbers: false, |
||
| 107 | timePicker: false, |
||
| 108 | timePickerIncrement: 1, |
||
| 109 | timePicker12Hour: true, |
||
| 110 | ranges: { |
||
| 111 | 'Today': [moment(), moment()], |
||
| 112 | 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], |
||
| 113 | 'Last 7 Days': [moment().subtract(6, 'days'), moment()], |
||
| 114 | 'Last 30 Days': [moment().subtract(29, 'days'), moment()], |
||
| 115 | 'This Month': [moment().startOf('month'), moment().endOf('month')], |
||
| 116 | 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] |
||
| 117 | }, |
||
| 118 | opens: 'left', |
||
| 119 | drops: 'down', |
||
| 120 | buttonClasses: ['btn', 'btn-sm'], |
||
| 121 | applyClass: 'btn-success', |
||
| 122 | cancelClass: 'btn-light', |
||
| 123 | separator: ' to ', |
||
| 124 | locale: { |
||
| 125 | applyLabel: 'Submit', |
||
| 126 | cancelLabel: 'Cancel', |
||
| 127 | fromLabel: 'From', |
||
| 128 | toLabel: 'To', |
||
| 129 | customRangeLabel: 'Custom', |
||
| 130 | daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], |
||
| 131 | monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], |
||
| 132 | firstDay: 1 |
||
| 133 | } |
||
| 134 | }, function (start, end, label) { |
||
| 135 | console.log(start.toISOString(), end.toISOString(), label); |
||
|
|
|||
| 136 | $('.reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY')); |
||
| 137 | }); |
||
| 138 | } |
||
| 139 | } |